﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3
{
    public partial class WebForm15 : System.Web.UI.Page
    {
        private DataClassesHealthDataContext dc = new DataClassesHealthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Bind();
            }
        }
        public void Bind()
        {
            string srt = Request.QueryString["str"];
            var policy = this.dc.policies.Join(this.dc.HospitalInfos, h => h.hospitalid, p => p.hospitalid, (h, p) => new
            {
                h.policyname,
                h.policydesc,
                h.amount,
                h.emi,
                p.hospitalname,
                p.hospitalid
            }).Where(b => b.policyname.Contains(srt)).ToList();
            if (policy.Count > 0)
            {

                this.GridView1.DataSource = policy;
                this.GridView1.DataBind();
            }
            else
            {
                this.LabelKqtQua.Text = "<h3>Policy does not exist</h3";

            }

        }




        protected void GridView1_PageIndexChanged1(object sender, GridViewPageEventArgs e)
        {

            GridView1.PageIndex = e.NewPageIndex;
            Bind();
        }

    }
}